package api

import (
	"gateway/basic/config"
	__ "gateway/basic/proto"
	"gateway/handler/request"
	"gateway/handler/resp"
	"github.com/gin-gonic/gin"
)

func OrderCreate(c *gin.Context) {
	//接收参数
	var req request.OrderCreate
	if err := c.ShouldBind(&req); err != nil {
		resp.Error(c, 400, "参数接收错误", err.Error())
		return
	}
	//业务逻辑
	_, err := config.ClearClient.Reservation(c, &__.ReservationReq{
		UserId:      req.UserId,
		Address:     req.Address,
		CleanerAre:  req.CleanerAre,
		CleanerType: req.CleanerType,
	})
	if err != nil {
		resp.Error(c, 400, "服务层错误", err.Error())
		return
	}
	resp.Success(c, true)
}

func ListOrder(c *gin.Context) {
	//接收参数
	var req request.List
	if err := c.ShouldBind(&req); err != nil {
		resp.Error(c, 400, "参数接收错误", err.Error())
		return
	}
	//业务逻辑
	date, err := config.ClearClient.OrderList(c, &__.OrderListReq{PayStatus: req.PayStatus})
	if err != nil {
		resp.Error(c, 400, "服务层错误", err.Error())
		return
	}
	resp.Success(c, date)
}
